import { FormSchema } from '/@/components/Table';
import { useTreeListStore } from '/@/store/modules/treeList';
const { currencyTreeList } = useTreeListStore();
import { h, unref } from 'vue';
import { FormItemRest, InputNumber } from 'ant-design-vue';
import { useFormSetting } from '/@/hooks/setting/useFormSetting';
import { useAutoLabelWidth } from '/@/components/Form/src/hooks/useForm';

const FORM_SIZE = useFormSetting().getFormSize;
export const getSchemaBase = (type: string) => {
  if (type == 'bet_limit') {
    // return [
    //   ...currencyTreeList.map(item => {
    //     return {
    //       field: 'c'+item.id,
    //       label: item.name + '投注限额',
    //       component: 'InputNumber',
    //       defaultValue: [null, null],
    //       colProps: {
    //         span: 18,
    //       },
    //       componentProps: {
    //         placeholder:'最低投注额'
    //       },
    //       render: ({ model, field }) => {
    //       return h(FormItemRest, null, () =>
    //         h('div', { class: 'flex justify-between items-center' }, [
    //           h(InputNumber, {
    //             stringMode: true,
    //             size: unref(FORM_SIZE),
    //             style: { width: '45%' },
    //             placeholder: '最低投注金额',
    //             value: model[field],
    //             onChange: (e) => {
    //               model[field]= e;
    //               //model.amount_min = e;
    //             },
    //           }),
    //           h('span', null, '—'),
    //           h(InputNumber, {
    //             stringMode: true,
    //             size: unref(FORM_SIZE),
    //             style: { width: '45%' },
    //             placeholder: '最高投注金额',
    //             value: model[field],
    //             max: 999999999,
    //             onChange: (e) => {
    //               model[field] = e;
    //               //model.amount_max = e;
    //             },
    //           }),
    //     ]),
    //   );
    // },
    //     }
    //   })
    // ]
  } else {
    return [
      {
        field: 'min_withdraw',
        label: '最低取款1',
        component: 'InputNumber',
        required: true,
        colProps: {
          span: 24,
        },
        componentProps: {
          placeholder: '请输入最低取款金额，0不限制',
        },
        renderComponentContent: () => {
          return {
            addonAfter: () => 'USDT',
          };
        },
      },
      {
        field: 'min_deposit',
        label: '最低存款',
        component: 'InputNumber',
        required: true,
        componentProps: {
          placeholder: '请输入最低存款金额，0不限制',
        },
        colProps: {
          span: 24,
        },
        renderComponentContent: () => {
          return {
            addonAfter: () => 'USDT',
          };
        },
      },
    ];
  }
};

export const schema: FormSchema[] = [
  {
    field: 'title',
    label: '',
    component: 'Input',
    slot: 'site-form',
    colProps: {
      span: 24,
    },
  },
];

export const schemaTable: FormSchema[] = [
  {
    field: 'min_withdraw',
    label: '最低取款',
    component: 'InputNumber',
    slot: 'minWithdraw',
    required: true,
    colProps: {
      span: 24,
    },
  },
  {
    field: 'min_deposit',
    label: '最低存款',
    component: 'InputNumber',
    slot: 'minDeposit',
    required: true,
    colProps: {
      span: 24,
    },
  },
];

useAutoLabelWidth(schemaTable);
